<template>
  <div class="container-fuild">
    <div class="row page-titles">
      <ol class="breadcrumb">
        <li class="breadcrumb-item active">教师管理 /</li>
        <li class="breadcrumb-item">实训班教师</li>
      </ol>
    </div>
    <div class="row">
      <div class="card">
        <div class="card-header">
          <p class="card-title">实训班教师</p>
        </div>
        <div class="card-body custom-ekeditor">
          <div id="ckeditor">
            <template>
              <el-table :data="tableData" style="width: 100%; color: #7d94c0">
                <el-table-column prop="className" label="实训班" width="280">
                  <!-- <template>
                    <i class="el-icon-user"></i>
                    <span style="margin-left: 10px">{{classname}}</span>
                  </template> -->
                </el-table-column>
                <el-table-column
                  prop="teacherName"
                  label="实训班教师"
                  width="280"
                >
                  <!-- <template>
                    <i class="el-icon-user"></i>
                    <span style="margin-left: 10px">{{teachername}}</span>
                  </template> -->
                </el-table-column>

                <el-table-column label="操作" style="margin-left: 100px; text-align:center">
                  <template slot-scope="scope">
                    <el-button
                      type="text"
                      size="mini"
                      style="background-color: steelblue; color: white; width:70px"
                      @click="dialogFormVisible = true"
                      >添加
                    </el-button>
                    <el-button
                      type="text"
                      size="mini"
                      style="background-color: steelblue; color: white;width:70px"
                      @click="dele(scope.row)"
                      >删除
                    </el-button>
                    <el-dialog
                      title="教师信息"
                      :visible.sync="dialogFormVisible"
                      style="font-weight: bold"
                      append-to-body
                      width="70%"
                      class="showAll_dialog"
                    >
                      <el-form :model="form">
                        <el-form-item
                          label="姓名"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.teacherName"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="电话"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.phone"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="职责"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.title"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="邮件"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.email"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="性别"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.gender"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="简介"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.introduct"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                      </el-form>
                      <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false"
                          >取 消</el-button
                        >
                        <el-button
                          type="primary"
                          @click="onSubmit"
                          >确 定</el-button
                        >
                      </div>
                    </el-dialog>
                  </template>
                </el-table-column>
              </el-table>
            </template>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name:"Addclassteacher",
  data() {
    return {
      tableData: [],
      dialogFormVisible:false,
      form: {
        teacherName: "",
        phone: "",
        title: "",
        email: "",
        gender: "",
        introduct: "",
      },
      formLabelWidth: "120px",
    };
  },
  mounted(){
    this.teacherShow();
  },
  methods: {
    onSubmit() {
      console.log(this.form);
      this.$axios.post("http://localhost:9090/user/addTeacher", this.form).then(alert("成功，请刷新界面"));
    },
    teacherShow(){
      let _this = this;
      this.$axios.get("http://localhost:9090/user/getTeacher").then(function(res){
        // console.log(res.data);
        _this.tableData =res.data.data;

      });
    },
    dele(e){
      console.log(e.className)
       this.$axios.post("http://localhost:9090/user/deleteTeacher",{className:e.className}).then(alert("成功，请刷新界面"));
    }
    
  },
};
</script>

<style scoped>
/*表头*/
.container-fuild {
  float: left;
  /*padding-top:1.875rem;*/
  padding-right: 1.875rem;
  padding-left: 1.875rem;
  width: 93%;
  margin-right: auto;
  margin-left: auto;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  color: #7d94c0;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.page-titles {
  justify-content: space-between;
  /*padding: 0.1375rem 0.5rem;*/
  padding-top: 0.25rem;
  padding-right: 1.875rem;
  padding-bottom: 0.25rem;
  padding-left: 1.875rem;
  background: #fff;
  margin-bottom: 1.875rem;
  border-radius: 1rem;
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
  --bs-gutter-x: 30px;
  --bs-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
}

.page-titles .breadcrumb {
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  font-size: 1.1875rem;
  display: flex;
  flex-wrap: wrap;
  padding: 0 0;
  margin-bottom: 1rem;
  list-style: none;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
}

.breadcrumb li.active {
  font-weight: 600;
  font-size: 1.1875rem;
}

.breadcrumb li {
  margin-top: 0;
  margin-bottom: 0;
  padding-left: 0.5rem;
  font-size: 1.1875rem;
}

/*主题部分*/
.row {
  --bs-gutter-x: 30px;
  --bs-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
  margin-top: calc(var(--bs-gutter-y) * -1);
  margin-right: calc(var(--bs-gutter-x) / -2);
  margin-left: calc(var(--bs-gutter-x) / -2);
}

.card {
  width: 100%;
  margin-bottom: 1.875rem;
  background-color: #fff;
  transition: all 0.5s ease-in-out;
  position: relative;
  border: 0rem solid transparent;
  border-radius: 1.25rem;
  box-shadow: 0rem 0.3125rem 0.3125rem 0rem rgb(82 63 105 / 5%);
  height: calc(100% - 30px);

  display: flex;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-color: #fff;
  background-clip: border-box;
}

.card-header {
  border-color: #f5f5f5;
  position: relative;
  background: transparent;
  padding-top: 0rem;
  padding-right: 1.875rem;
  padding-bottom: 0rem;
  padding-left: 1.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  font-size: 1.1rem;
  font-weight: 300;
  color: #909399;
  text-transform: capitalize;
}

.card-body {
  padding-top: 0.125rem;
  padding-right: 1.875rem;
  padding-bottom: 1.125rem;
  padding-left: 1.875rem;

  flex-grow: 1;
  flex-shrink: 1;
  flex-basis: auto;
}

.table-responsive-md {
  min-width: 36rem !important;
}

/*弹窗*/
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}

/*让dialog能够悬浮在中间*/
.showAll_dialog {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
}

::v-deep .el-dialog {
  margin: 0 auto !important;
  height: 80%;
  overflow: auto;
  background-color: white;
}

.el-dialog__body {
  position: absolute;
  left: 0;
  top: 54px;
  bottom: 0;
  right: 0;
  z-index: 1;
  overflow: hidden;
  overflow-y: auto;

  line-height: 30px;
  padding: 15px;
}

/*弹窗标题的padding*/
::v-deep .el-dialog__header {
  padding-top: 20px;
  padding-right: 50px;
  padding-bottom: 10px;
  padding-left: 50px;
}
/*弹窗标题的padding*/
::v-deep .el-dialog__header {
  padding-top: 30px;
  padding-right: 50px;
  padding-bottom: 30px;
  padding-left: 50px;
}

/*弹窗标题的颜色*/
::v-deep .el-dialog__title {
  color: #909399;
}

/*弹窗尾部按钮颜色*/
.el-button--primary {
  color: #fff;
  background-color: #016bb7;
  border-color: #016bb7;
}

::v-deep .el-button {
  border-radius: 5px;
}
</style>